package com.irdstudio.efp.riskm.service.impl;

import com.irdstudio.basic.framework.core.base.FrameworkService;
import com.irdstudio.efp.riskm.service.dao.PspSpecCheckTempDao;
import com.irdstudio.efp.riskm.service.domain.PspSpecCheckCus;
import com.irdstudio.efp.riskm.service.domain.PspSpecCheckTemp;
import com.irdstudio.efp.riskm.service.facade.PspSpecCheckTempService;
import com.irdstudio.efp.riskm.service.vo.PspSpecCheckCusVO;
import com.irdstudio.efp.riskm.service.vo.PspSpecCheckTempVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 需求编号：【2019D0509】（业务提的需求编号）
 * 问题编号：【】（若不是因为修复问题而新增该类，则留空）
 * 开发人员：【wanglh4】
 * 创建日期：【2019/12/5 10:34】
 * 功能描述：
 */
@Service("pspSpecCheckTempService")
public class PspSpecCheckTempServiceImpl implements PspSpecCheckTempService, FrameworkService {

    private static Logger logger = LoggerFactory.getLogger(PspSpecCheckTempServiceImpl.class);

    @Autowired
    private PspSpecCheckTempDao pspSpecCheckTempDao;

    @Override
    public int deleteAllDatas() {
        logger.info("开始清空临时表数据！");
        int num = 0;
        try {
            num = pspSpecCheckTempDao.deleteAllDatas();
        } catch (Exception e) {
            logger.info("删除数据出错！");
        }
        return num;
    }

    @Override
    public int batchInsertDatas(List<PspSpecCheckTempVO> tempList) {
        logger.debug("当前修改数据为:"+ tempList.toString());
        int num = 0;
        try {
            num = pspSpecCheckTempDao.batchInsertDatas(tempList);
        } catch (Exception e) {
            logger.error("修改数据发生异常!", e);
            num = -1;
        }
        logger.debug("根据条件:"+ tempList.toString() +"修改的数据条数为"+ num);
        return num;
    }

    @Override
    public List<PspSpecCheckTempVO> queryDatasByPage(PspSpecCheckTempVO pspSpecCheckTempVO) {
        logger.debug("当前查询信息为为:"+ pspSpecCheckTempVO.toString());
        List<PspSpecCheckTempVO> list = null;
        try {
            List<PspSpecCheckTemp> pspSpecCheckTemp = pspSpecCheckTempDao.queryDatasByPage(pspSpecCheckTempVO);
            logger.debug("当前查询本人所属数据信息的结果集数量为:"+ pspSpecCheckTemp.size());
            pageSet(pspSpecCheckTemp, pspSpecCheckTempVO);
            list = (List<PspSpecCheckTempVO>) beansCopy(pspSpecCheckTemp, PspSpecCheckTempVO.class);
        } catch (Exception e) {
            logger.error("数据转换出现异常!", e);
        }
        return list;
    }

    @Override
    public List<PspSpecCheckTempVO> queryAllDatas() {
        logger.debug("当前查询信息为为:");
        List<PspSpecCheckTempVO> list = null;
        try {
            List<PspSpecCheckTemp> pspSpecCheckTemp = pspSpecCheckTempDao.queryAllDatas();
            logger.debug("当前查询本人所属数据信息的结果集数量为:"+ pspSpecCheckTemp.size());
            list = (List<PspSpecCheckTempVO>) beansCopy(pspSpecCheckTemp, PspSpecCheckTempVO.class);
        } catch (Exception e) {
            logger.error("数据转换出现异常!", e);
        }
        return list;
    }
}
